package com.biz.primus.ms.oms.trans;

import com.biz.primus.model.oms.vo.OmsPaymentVo;
import com.biz.primus.ms.base.service.IdService;
import com.biz.primus.ms.oms.dao.po.OrderPaymentInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author yanweijin
 * @date 2017/11/17
 */
@Component
public class PaymentConverter {

	@Autowired
	private IdService idService;



	public List<OrderPaymentInfo> vo2po(List<OmsPaymentVo> payments, Long orderId){
		return payments.stream().map(p->{
			OrderPaymentInfo info = new OrderPaymentInfo();
			info.setId(idService.getNextId());
			info.setOrderId(orderId);
			info.setPaidAmount(p.getPaidAmount());
			info.setPaidTime(p.getPaidTime());
			info.setPaymentWay(p.getPaymentWay());
			info.setTradeNo(p.getTradeNo());
			return info;
		}).collect(Collectors.toList());
	}



}
